<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
    <base href="<%=basePath%>">
	<link rel="stylesheet" type="text/css" href="bootstrap-rs/themes/black/easyui.css">
	<link rel="stylesheet" type="text/css" href="bootstrap-rs/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="bootstrap-rs/demo.css">
	<script type="text/javascript" src="bootstrap-rs/jquery.min.js"></script>
	<script type="text/javascript" src="bootstrap-rs/jquery.easyui.min.js"></script>
</head>
<body>
	<table id="dg" class="easyui-datagrid" title="分级规则列表" style="width:900px;height:250px"
			data-options="
			rownumbers:true,
			singleSelect:false,
			url:'',
			fit:true, // 自动适配父容器的宽高
			striped:true,// 行条纹化
			fitColumns:true,
			pagination:true,
			pagePosition:'bottom',
			method:'post'">
		<thead>
			<tr>
				<th data-options="field:'rulename',width:80,align:'center'">规则名称</th>
				<th data-options="field:'brand',width:80,align:'center'">品牌</th>
				<th data-options="field:'grade',width:80,align:'center'">VIP等级</th>
				<th data-options="field:'factor',width:100,align:'center'"">计算系数</th>
				<th data-options="field:'priority',width:220,align:'center'">优先级</th>
				<th data-options="field:'status',width:80,align:'center'">状态</th>
				<th data-options="field:'manual',width:100,align:'center'">操作</th>
			</tr>
		</thead>
 		<c:forEach items="${list }" var="dto">
    		<tr>
	            <td>${dto.gradeRule.vRulename }</td>
	            <td>${dto.vBrandname}</td>
	            <td>${dto.vGrade }</td>
	            <td>${dto.gradeRule.nFactor }</td>
	            <td>${dto.gradeRule.nPriority }</td>
	            <td>${dto.gradeRule.vFrozen }</td>
	            <td>
	            <c:if test="${dto.gradeRule.vFrozen eq '正常'}">
	            	<a href="rule/info/queryDetails?id=${dto.gradeRule.nRuleno }">查看</a>
	            	<a href="" onclick="lockRule(${dto.gradeRule.nRuleno });return false;">锁定</a>
	            	<a href="rule/info/getInfoById?id=${dto.gradeRule.nRuleno }">修改</a>
	            	<a href="" onclick="deleteRule(${dto.gradeRule.nRuleno });return false;">删除</a>
	            </c:if>
	            <c:if test="${dto.gradeRule.vFrozen eq '冻结'}">
	            	<a href="rule/info/queryDetails?id=${dto.gradeRule.nRuleno }">查看</a>
	            	<a href="" onclick="unlockRule(${dto.gradeRule.nRuleno });return false;">解锁</a>
	            </c:if>
	           </td>
	        </tr>
    	</c:forEach>
		
	</table>

<div id="tb" align="center">
<%-- 		品牌： 
			<!-- <select id="brand" onchange="chooseBrand(this)"> -->
			<select id="brand" >
				<option value="--请选择--"}>--请选择--
				<option value="世界风" ${brandName == '世界风'?'selected':''}>世界风
				<option value="新势力" ${brandName == '新势力'?'selected':''}>新势力
				<option value="新时空" ${brandName == '新时空'?'selected':''}>新时空
				<option value="如意通" ${brandName == '如意通'?'selected':''}>如意通
			</select>
			等级：
			<!-- <select id="grade" onchange="chooseGrade(this)"> -->
			<select id="grade" >
				<option value="--请选择--"}>--请选择--
				<option value="钻石卡" ${gradeName == '钻石卡'?'selected':''}>钻石卡
				<option value="金卡" ${gradeName == '金卡'?'selected':''}>金卡
				<option value="银卡" ${gradeName == '银卡'?'selected':''}>银卡
			</select> --%>
 		品牌：
		<select id="brand" name="brand">
			<option value="0">--请选择--</option>
			<c:forEach var="brand" items="${brandList }" varStatus="status">
				<option  name="brandName" value="${brand.vBrandname}" >${brand.vBrandname}</option>
			</c:forEach>
		</select>
		等级：
		<select id="grade" name="grade">
			<option value="0">--请选择--</option>
			<c:forEach var="grade" items="${gradeList }" varStatus="status">
				<option  name="gradeName" value="${grade.vGrade }" >${grade.vGrade }</option>
			</c:forEach>
		</select>			
		
		<input type="button" name="rulelist_query" value="查询" onclick="queryByName()">
		<input type="button" name="rule_add" value="添加规则" onclick="addRule()">
</div>

</body>
<script type="text/javascript">
$('#dg').datagrid({
	toolbar: '#tb'
});

/* function chooseBrand(opt){
	window.location.href ="/rule/info/queryByBrand?brandName="+opt.options[opt.selectedIndex].value;
}

function chooseGrade(opt){
	window.location.href ="/rule/info/queryByGrade?gradeName="+opt.options[opt.selectedIndex].value;
} */

function queryByName(){
	window.location.href = "/rule/info/queryByName?brandName="+
			$('#brand').val()+"&gradeName="+$('#grade').val();
}

function addRule(){
	window.location.href='rule/info/toAddRule';
}

function deleteRule(ruleno){
var flag = window.confirm("确定要删除此规则吗？");
	if(flag == true){
	window.location.href = "rule/info/deleteRule?id="+ruleno;
	}
}

function lockRule(ruleno){
var flag = window.confirm("确定要锁定此规则吗？");
	if(flag == true){
	window.location.href = "rule/info/lockRule?id="+ruleno;
	}
}

function unlockRule(ruleno){
var flag = window.confirm("确定要解锁此规则吗？");
	if(flag == true){
	window.location.href = "rule/info/unlockRule?id="+ruleno;
	}
}
</script>
</html>